
#include <stdio.h>
#include <stdlib.h>
#include "lc_filereader.h"
#include "lc_array.h"
#include <string.h>

LCarray* fileToArray(char * filename)
{

    FILE *file;
    int nbLines = 1;
    int currentLine = 0;
    char ligne_lue[512];
    LCarray *array;


    file = fopen (filename, "rt");
    array = lcArrayCreate();


    if (file == NULL) {
        fprintf(stderr, "Can't open file!\n");
        exit(1);
    }


    while (fgets(ligne_lue, 512, file) != NULL) {
        nbLines++;
    }

    rewind(file);

    char lines[nbLines][254];
    while (fscanf(file, "%s", lines[currentLine]) != EOF && currentLine < nbLines) {
        printf("current : %s\n",lines[currentLine]);
        lcArrayAdd(array, lines[currentLine]);
        currentLine++;
    }

    fclose(file);

    return array;
}



